/*** In The Name of Allah ***/
package com.codeanalysissys.backend.graphs.pdg;

import java.io.IOException;
import java.io.InputStream;

import com.codeanalysissys.backend.cpp.CppPDGBuilder;
import com.codeanalysissys.backend.golang.GoPDGBuilder;
import com.codeanalysissys.backend.java.JavaPDGBuilder;
import com.codeanalysissys.backend.javascript.JavaScriptPDBGuilder;
import com.codeanalysissys.backend.python.PythonPDGBuilder;
import com.codeanalysissys.backend.ruby.RubyPDGBuilder;

/**
 * Program Dependence Graph (PDG) Builder.
 * This class invokes the appropriate builder based on the given language parameter.
 *
 * @author Seyed Mohammad Ghaffarian
 */
public class PDGBuilder {
	public static ProgramDependeceGraph buildForOne(String lang, String fileName, InputStream inputStream) throws IOException {
		switch (lang) {
			case "Cpp":
				return CppPDGBuilder.buildForOne(fileName,inputStream);
			//
			case "C":
				return null;
			//
			case "Java":
				return JavaPDGBuilder.buildForOne(fileName,inputStream);
			//
			case "Python":
//				return PythonPDGBuilder.buildForOne(fileName, inputStream);
				return null;
			//
			case "Golang":
				return GoPDGBuilder.buildForAll(fileName,inputStream);
			case"Ruby":
				return RubyPDGBuilder.buildForOne(fileName, inputStream);
			//
			default:
				return null;
		}
	}
	
	public static ProgramDependeceGraph[] buildForAll(String lang, String[] srcFilePaths) throws IOException {
		switch (lang) {
			case "Cpp":
				return CppPDGBuilder.buildForAll(srcFilePaths);
			//
			case "C":
				return null;
			//
			case "Java":
				return JavaPDGBuilder.buildForAll(srcFilePaths);
			case "JavaScript":
				return JavaScriptPDBGuilder.buildForAll(srcFilePaths);
			//
			case "Python":
				return PythonPDGBuilder.buildForAll(srcFilePaths);
			//
			case "Golang":
				return GoPDGBuilder.buildForAll(srcFilePaths);
			case "Ruby":
				return RubyPDGBuilder.buildForAll(srcFilePaths);
			//
			default:
				return null;
		}
	}

	public static ProgramDependeceGraph build(String lang, InputStream content) throws IOException {
		switch (lang) {
			case "Cpp":
				return CppPDGBuilder.build(content);
			//
			case "C":
				return null;
			//
			case "Java":
				return JavaPDGBuilder.build(content);
			case "JavaScript":
				return JavaScriptPDBGuilder.build(content);
			//
			case "Python":
				return PythonPDGBuilder.build(content);
			//
			case "Golang":
				return GoPDGBuilder.build(content);
			case "Ruby":
				return RubyPDGBuilder.build(content);
			//
			default:
				return null;
		}
	}


}
